//  package cn.org.intelli.zffserver.controller;
//
//
//  import cn.org.intelli.zffserver.aop.AuthenticationTicket;
//  import cn.org.intelli.zffserver.domain.BackBean;
//  import cn.org.intelli.zffserver.domain.DataBasePattern;
//  import cn.org.intelli.zffserver.entity.DataBaseEntity;
//  import cn.org.intelli.zffserver.entity.DataBaseV2Entity;
//  import cn.org.intelli.zffserver.repository.DataBaseRepository;
//  import cn.org.intelli.zffserver.repository.DataBaseV2Repository;
//  import cn.org.intelli.zffserver.util.Uid;
//  import com.alibaba.fastjson.JSON;
//  import com.alibaba.fastjson.JSONArray;
//  import com.alibaba.fastjson.JSONObject;
//  import dm.jdbc.util.StringUtil;
//  import java.util.Date;
//  import java.util.List;
//  import java.util.Map;
//  import org.slf4j.Logger;
//  import org.slf4j.LoggerFactory;
//  import org.springframework.beans.factory.annotation.Autowired;
//  import org.springframework.data.domain.Page;
//  import org.springframework.data.domain.PageRequest;
//  import org.springframework.data.domain.Pageable;
//  import org.springframework.data.domain.Sort;
//  import org.springframework.data.jpa.domain.Specification;
//  import org.springframework.data.repository.query.Param;
//  import org.springframework.web.bind.annotation.GetMapping;
//  import org.springframework.web.bind.annotation.PathVariable;
//  import org.springframework.web.bind.annotation.PostMapping;
//  import org.springframework.web.bind.annotation.RequestBody;
//  import org.springframework.web.bind.annotation.RequestMapping;
//  import org.springframework.web.bind.annotation.RequestParam;
//  import org.springframework.web.bind.annotation.RestController;
//
//
//
//  @RestController
//  @RequestMapping({"/dbSource"})
//  public class DataBaseController
//  {
///*  41 */   private static final Logger log = LoggerFactory.getLogger(cn.org.intelli.zffserver.controller.DataBaseController.class);
//
//
//    @Autowired
//    private DataBaseRepository dataBaseRepository;
//
//
//    @Autowired
//    private DataBaseV2Repository dataBaseV2Repository;
//
//    @Autowired
//    private DataBasePattern dataBasePattern;
//
//
//    @GetMapping({"/getDataBasePatterns"})
//    public BackBean<JSONObject> getDataBasePatterns() {
//      try {
///*  58 */       return BackBean.builder().status(true).data(this.dataBasePattern.getDbPatterns()).build();
///*  59 */     } catch (Exception e) {
///*  60 */       e.printStackTrace();
///*  61 */       log.error("@GetDataBasePatterns: error is {}", e.getMessage());
///*  62 */       return BackBean.builder().status(false).message(e.getMessage()).build();
//      }
//    }
//
//
//
//
//
//
//    @PostMapping({"/createDataBaseSource"})
//    public BackBean<String> createDataBaseSourceV2(@RequestBody JSONObject dbInfo) {
//      try {
///*  74 */       DataBaseV2Entity db = new DataBaseV2Entity();
///*  75 */       db.setCreateTime(new Date());
///*  76 */       String id = Uid.generateShortUuid();
///*  77 */       db.setId(id);
///*  78 */       db.setDbInfo(dbInfo.toJSONString());
//
///*  80 */       String rdbName = dbInfo.getString("rdbName");
///*  81 */       String dbType = dbInfo.getString("dbType");
///*  82 */       String rwType = dbInfo.getString("rwType");
//
///*  84 */       db.setRdbName(rdbName);
///*  85 */       db.setDbType(dbType);
///*  86 */       db.setRwType(rwType);
//
///*  88 */       this.dataBaseV2Repository.save(db);
///*  89 */       return BackBean.builder().status(true).data("success").build();
///*  90 */     } catch (Exception e) {
///*  91 */       e.printStackTrace();
///*  92 */       log.error("@CreateDataBaseSourceV2: error is {}", e.getMessage());
///*  93 */       return BackBean.builder().status(false).message(e.getMessage()).build();
//      }
//    }
//
//
//
//
//
//
//    @GetMapping({"/getDataBaseDetail"})
//    public BackBean<JSONObject> getDataBaseDetailV2(@RequestParam("dbId") String dbId) {
//      try {
///* 105 */       DataBaseV2Entity db = this.dataBaseV2Repository.findById(dbId).get();
///* 106 */       JSONObject dbInfo = JSON.parseObject(db.getDbInfo());
///* 107 */       JSONObject all = JSON.parseObject(JSON.toJSONString(db));
///* 108 */       all.remove("dbInfo");
///* 109 */       dbInfo.putAll((Map)all);
///* 110 */       return BackBean.builder().status(true).data(dbInfo).build();
///* 111 */     } catch (Exception e) {
///* 112 */       e.printStackTrace();
///* 113 */       log.error("@GetDataBaseDetailV2: error is {}", e.getMessage());
///* 114 */       return BackBean.builder().status(false).message(e.getMessage()).build();
//      }
//    }
//
//
//
//
//
//
//
//
//    @PostMapping({"/updateDataBaseSource/{dbId}"})
//    public BackBean<String> updateDataBaseSourceV2(@PathVariable("dbId") String dbId, @RequestBody JSONObject dbInfo) {
//      try {
///* 128 */       DataBaseV2Entity db = this.dataBaseV2Repository.findById(dbId).get();
///* 129 */       db.setDbInfo(dbInfo.toJSONString());
///* 130 */       db.setRdbName(dbInfo.getString("rdbName"));
///* 131 */       db.setDbType(dbInfo.getString("dbType"));
///* 132 */       db.setRwType(dbInfo.getString("rwType"));
///* 133 */       db.setUpdateTime(new Date());
///* 134 */       this.dataBaseV2Repository.save(db);
///* 135 */       return BackBean.builder().status(true).data("success").build();
///* 136 */     } catch (Exception e) {
///* 137 */       e.printStackTrace();
///* 138 */       log.error("@UpdateDataBaseSourceV2: error is {}", e.getMessage());
///* 139 */       return BackBean.builder().status(false).message(e.getMessage()).build();
//      }
//    }
//
//
//
//
//
//
//
//
//
//
//
//
//    @GetMapping({"/getDataBasesByPage"})
//    public BackBean<JSONArray> getDataBasesByPageV2(@RequestParam(name = "page", defaultValue = "1") Integer page, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, @Param("rdbName") String rdbName, @Param("dbType") String dbType) {
//      try {
///* 157 */       Sort sort = new Sort(new Sort.Order[] { new Sort.Order(Sort.Direction.DESC, "createTime") });
///* 158 */       PageRequest pageRequest = PageRequest.of(page.intValue() - 1, pageSize.intValue(), sort);
//
///* 160 */       Page<DataBaseV2Entity> dataBasePage = this.dataBaseV2Repository.findAll((Specification)new Object(this, rdbName, dbType), (Pageable)pageRequest);
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
///* 178 */       JSONArray result = new JSONArray();
///* 179 */       for (DataBaseV2Entity db : dataBasePage.getContent()) {
///* 180 */         JSONObject dbInfo = JSON.parseObject(db.getDbInfo());
///* 181 */         JSONObject allInfo = JSON.parseObject(JSON.toJSONString(db));
///* 182 */         allInfo.remove("dbInfo");
///* 183 */         dbInfo.putAll((Map)allInfo);
///* 184 */         result.add(dbInfo);
//        }
//
///* 187 */       return BackBean.builder().status(true)
///* 188 */         .data(result).totalNum(Long.valueOf(dataBasePage.getTotalElements())).build();
///* 189 */     } catch (Exception e) {
///* 190 */       e.printStackTrace();
///* 191 */       log.error("@GetDataDasesByPageV2: error is {}", e.getMessage());
///* 192 */       return BackBean.builder().status(false).message(e.getMessage()).build();
//      }
//    }
//
//
//
//
//
//
//    @PostMapping({"/createDataBaseSource_bakup"})
//    public BackBean<String> createDataBaseSource(@RequestBody DataBaseEntity db) {
//      try {
///* 204 */       String id = Uid.generateShortUuid();
///* 205 */       db.setId(id);
///* 206 */       this.dataBaseRepository.save(db);
///* 207 */       return BackBean.builder().status(true).data("success").build();
///* 208 */     } catch (Exception e) {
///* 209 */       e.printStackTrace();
///* 210 */       log.error("@CreateDataBaseSource: error is {}", e.getMessage());
///* 211 */       return BackBean.builder().status(false).message(e.getMessage()).build();
//      }
//    }
//
//
//
//
//
//
//
//
//    @PostMapping({"/updateDataBaseSource_bakup/{dbId}"})
//    public BackBean<String> updateDataBaseSource(@PathVariable("dbId") String dbId, @RequestBody DataBaseEntity db) {
//      try {
///* 225 */       DataBaseEntity oriDb = this.dataBaseRepository.findById(dbId).get();
///* 226 */       if (StringUtil.isNotEmpty(db.getDriverName())) {
///* 227 */         oriDb.setDriverName(db.getDriverName());
//        }
///* 229 */       if (StringUtil.isNotEmpty(db.getSchemaName())) {
///* 230 */         oriDb.setSchemaName(db.getSchemaName());
//        }
///* 232 */       if (StringUtil.isNotEmpty(db.getDbUrl())) {
///* 233 */         oriDb.setDbUrl(db.getDbUrl());
//        }
///* 235 */       if (StringUtil.isNotEmpty(db.getDbUserName())) {
///* 236 */         oriDb.setDbUserName(db.getDbUserName());
//        }
///* 238 */       if (StringUtil.isNotEmpty(db.getDbPassword())) {
///* 239 */         oriDb.setDbPassword(db.getDbPassword());
//        }
///* 241 */       if (StringUtil.isNotEmpty(db.getRdbName())) {
///* 242 */         oriDb.setRdbName(db.getRdbName());
//        }
///* 244 */       if (StringUtil.isNotEmpty(db.getRecord())) {
///* 245 */         oriDb.setRecord(db.getRecord());
//        }
///* 247 */       if (StringUtil.isNotEmpty(db.getDbType())) {
///* 248 */         oriDb.setDbType(db.getDbType());
//        }
///* 250 */       if (StringUtil.isNotEmpty(db.getClusterName())) {
///* 251 */         oriDb.setClusterName(db.getClusterName());
//        }
///* 253 */       if (StringUtil.isNotEmpty(db.getEngine())) {
///* 254 */         oriDb.setEngine(db.getEngine());
//        }
///* 256 */       this.dataBaseRepository.save(oriDb);
///* 257 */       return BackBean.builder().status(true).data("success").build();
///* 258 */     } catch (Exception e) {
///* 259 */       e.printStackTrace();
///* 260 */       log.error("@UpdateDataBaseSource: error is {}", e.getMessage());
///* 261 */       return BackBean.builder().status(false).message(e.getMessage()).build();
//      }
//    }
//
//
//
//
//
//
//    @GetMapping({"/getDataBaseDetail_bakup"})
//    public BackBean<DataBaseEntity> getDataBaseDetail(@RequestParam("dbId") String dbId) {
//      try {
///* 273 */       DataBaseEntity db = this.dataBaseRepository.findById(dbId).get();
///* 274 */       return BackBean.builder().status(true).data(db).build();
///* 275 */     } catch (Exception e) {
///* 276 */       e.printStackTrace();
///* 277 */       log.error("@GetDataBaseDetail: error is {}", e.getMessage());
///* 278 */       return BackBean.builder().status(false).message(e.getMessage()).build();
//      }
//    }
//
//
//
//
//
//
//
//
//
//
//
//
//    @GetMapping({"/getDataBasesByPage_bakup"})
//    public BackBean<List> getDataBasesByPage(@RequestParam(name = "page", defaultValue = "1") Integer page, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, @Param("rdbName") String rdbName, @Param("dbType") String dbType) {
//      try {
///* 296 */       String userPin = AuthenticationTicket.getTicket().getPin();
///* 297 */       Sort sort = new Sort(new Sort.Order[] { new Sort.Order(Sort.Direction.ASC, "createTime") });
///* 298 */       PageRequest pageRequest = PageRequest.of(page.intValue() - 1, pageSize.intValue(), sort);
//
///* 300 */       Page<DataBaseEntity> dataBasePage = this.dataBaseRepository.findAll((Specification)new Object(this, rdbName, dbType), (Pageable)pageRequest);
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
///* 318 */       return BackBean.builder()
///* 319 */         .status(true)
///* 320 */         .totalNum(Long.valueOf(dataBasePage.getTotalElements()))
///* 321 */         .data(dataBasePage.getContent()).build();
///* 322 */     } catch (Exception e) {
///* 323 */       e.printStackTrace();
///* 324 */       log.error("@GetDataBasesByPage: error is {}", e.getMessage());
///* 325 */       return BackBean.builder().status(false).message(e.getMessage()).build();
//      }
//    }
//  }
//
//
///* Location:              C:\Users\admin\Desktop\xxm\zjg11\ZjgCaculate-v1.0.jar!\BOOT-INF\classes\cn\org\intelli\zffserver\controller\DataBaseController.class
// * Java compiler version: 8 (52.0)
// * JD-Core Version:       1.1.3
// */